<template>
	<view>
		<!-- 分享 -->
		<u-popup :show="showShare" :round="10" mode="bottom" :closeOnClickOverlay="true" @close="closeShare">
			<view class="share-box">
				<view class="title">
					分享至
				</view>
				<view class="share-info">
					<view class="share-item" @click="weixinShare" v-if="isPcHuiyuan">
						<image src="@/static/img/Details/weixin.png" mode="widthFix"></image>
						<view>微信</view>
					</view>
					<view class="share-item" @click="ToShare" v-else>
						<image src="@/static/img/Details/weixin.png" mode="widthFix"></image>
						<view>微信</view>
					</view>
					<view class="share-item" @click="copyLink">
						<image src="@/static/img/Details/fuzhilianjie.png" mode="widthFix"></image>
						<view>复制链接</view>
					</view>
					<view class="share-item" @click="copyTitle">
						<image src="@/static/img/Details/fuzhibiaoti.png" mode="widthFix"></image>
						<view>复制信息标题</view>
					</view>
					<view class="share-item" @click="clickGengduo">
						<image src="@/static/img/Details/gengduo.png" mode="widthFix"></image>
						<view>更多</view>
					</view>
				</view>
			</view>
		</u-popup>
	</view>
</template>

<script>
	import  appShare,{ closeShare } from '@/common/static/share.js'
	export default {
		name: "popup-share",
		props: ['showShare', 'title', 'type', 'ids', "from","detailData",'comcode','vcode','danweiType'],
		data() {
			return {
				isPcHuiyuan: false,
			};
		},
		created() {

		},
		watch: {

		},
		computed: {

		},
		mounted() {
			//是否为pc会员
			this.isPcHuiyuan = uni.getStorageSync('userInfo').isPcHuiyuan || false
		},
		methods: {
			closeShare() {
				this.$emit('update:showShare', false)
			},
			/**
			 * 20241230张家铭需求
			 * PC会员直接分享给好友该小程序的页面（参考瑞幸咖啡）
			 * 移动会员-同当前的操作，ios与安卓有区别--跳转到m站对应信息
			 */
			//分享到微信好友卡片--pc会员
			weixinShare() {
				if (this.from == "zhaobiao") {
					uni.share({
						provider: 'weixin',
						scene: "WXSceneSession",
						type: 5,
						imageUrl: 'https://img.bidcenter.com.cn/uni/share.png',
						title: this.title,
						miniProgram: {
							id: 'gh_cd40829a4ca1',
							path: '/pagesOne/detail/detail-Biaoxun?id=' + this.ids,
							type: 0,
							webUrl: '/pagesOne/detail/detail-Biaoxun?id=' + this.ids
						},
						success: ret => {
							console.log(JSON.stringify(ret));
						}
					});
				} else if(this.from == "gongcheng"){
					uni.share({
						provider: 'weixin',
						scene: "WXSceneSession",
						type: 5,
						imageUrl: 'https://img.bidcenter.com.cn/uni/share.png',
						title: this.title,
						miniProgram: {
							id: 'gh_cd40829a4ca1',
							path: '/pagesOne/detail/detail-pro?id=' + this.ids,
							type: 0,
							webUrl: '/pagesOne/detail/detail-pro?id=' + this.ids
						},
						success: ret => {
							console.log(JSON.stringify(ret));
						}
					});
				}else if(this.from == "qiqing"){
					
					uni.share({
						provider: 'weixin',
						scene: "WXSceneSession",
						type: 5,
						imageUrl: 'https://img.bidcenter.com.cn/uni/share.png',
						title: this.title,
						miniProgram: {
							id: 'gh_cd40829a4ca1',
							path: 'pagesTwo/qiqing/index?comcode=' + this.comcode +'&vcode='+this.vcode +'&companyName='+this.title +'&type=' +this.danweiType+'&isFenxiang=1' ,
							type: 0,
							webUrl: 'pagesTwo/qiqing/index?comcode=' + this.comcode +'&vcode='+this.vcode+'&companyName='+this.title+'&type=' +this.danweiType +'&isFenxiang=1'
						},
						success: ret => {
							console.log(JSON.stringify(ret));
						}
					});
				}

			},

			//移动会员区分ios与安卓
			ToShare() {
				if ((uni.getSystemInfoSync().platform == 'ios' && this.ids > 0) || (uni.getSystemInfoSync().platform == 'ios' && this.comcode.length && this.vcode.length)) {
					this.closeShare()
					let shareData = {}
					if (this.from == 'zhaobiao') {
						shareData = {
							shareImg: 'https://img.bidcenter.com.cn/app/images/logo.png',
							shareUrl: "https://interface.bidcenter.com.cn/web/share/zbshare.aspx?id=" + this.ids,
							shareTitle: this.title || "采招网--招标网|招标公告|工程招标采购信息",
							shareContent: "中国采招网是招标网中致力于为企业提供招标、采购、拟在建项目信息及网上招标采购等服务的招标网;采招网是中国招标网站采购领域的最佳资讯和交易招标网站，为各级政府采购、招标代理机构、招标企业、供应商提供强大的专业招标采购信息查询和相关服务,中国第一招标网"
						};
					} else if(this.from == "gongcheng"){
						shareData = {
							shareImg: 'https://img.bidcenter.com.cn/app/images/logo.png',
							shareUrl: "https://interface.bidcenter.com.cn/web/share/xmshare.aspx?id=" + this.ids,
							shareTitle: this.title || "采招网--招标网|招标公告|工程招标采购信息",
							shareContent: "中国采招网是招标网中致力于为企业提供招标、采购、拟在建项目信息及网上招标采购等服务的招标网;采招网是中国招标网站采购领域的最佳资讯和交易招标网站，为各级政府采购、招标代理机构、招标企业、供应商提供强大的专业招标采购信息查询和相关服务,中国第一招标网"
						};
					}else if(this.from == "qiqing"){
						// 2:业主 5:供应 1:代理
						if(this.danweiType=='2'){
							shareData = {
								shareImg: 'https://img.bidcenter.com.cn/app/images/logo.png',
								shareUrl: "https://user.bidcenter.com.cn/v2023/#/saasApply/qiqing/zhaobiaofenxi/" + this.comcode+'/'+this.vcode,
								shareTitle: this.title || "采招网--招标网|招标公告|工程招标采购信息",
								shareContent: "中国采招网是招标网中致力于为企业提供招标、采购、拟在建项目信息及网上招标采购等服务的招标网;采招网是中国招标网站采购领域的最佳资讯和交易招标网站，为各级政府采购、招标代理机构、招标企业、供应商提供强大的专业招标采购信息查询和相关服务,中国第一招标网"
							};
						}else if(this.danweiType=='5'){
							shareData = {
								shareImg: 'https://img.bidcenter.com.cn/app/images/logo.png',
								shareUrl: "https://user.bidcenter.com.cn/v2023/#/saasApply/qiqing/zhongbiaofenxi/" + this.comcode+'/'+this.vcode,
								shareTitle: this.title || "采招网--招标网|招标公告|工程招标采购信息",
								shareContent: "中国采招网是招标网中致力于为企业提供招标、采购、拟在建项目信息及网上招标采购等服务的招标网;采招网是中国招标网站采购领域的最佳资讯和交易招标网站，为各级政府采购、招标代理机构、招标企业、供应商提供强大的专业招标采购信息查询和相关服务,中国第一招标网"
							};
						}else if(this.danweiType=='1'){
							shareData = {
								shareImg: 'https://img.bidcenter.com.cn/app/images/logo.png',
								shareUrl: "https://user.bidcenter.com.cn/v2023/#/saasApply/qiqing/dailifenxi/" + this.comcode+'/'+this.vcode,
								shareTitle: this.title || "采招网--招标网|招标公告|工程招标采购信息",
								shareContent: "中国采招网是招标网中致力于为企业提供招标、采购、拟在建项目信息及网上招标采购等服务的招标网;采招网是中国招标网站采购领域的最佳资讯和交易招标网站，为各级政府采购、招标代理机构、招标企业、供应商提供强大的专业招标采购信息查询和相关服务,中国第一招标网"
							};
						}
						
					}
					// 调用
					let shareObj = appShare(shareData, res => {
						console.log("分享成功回调", res);
						closeShare();
					});
				} else {
					let shareInfo = {
						href: "https://m.bidcenter.com.cn/help/downloadapp.shtml",
						title: this.title || "采招网-招标网|招标公告|工程招标采购信息",
						desc: this.title ||
							"中国采招网是招标网中致力于为企业提供招标、采购、拟在建项目信息及网上招标采购等服务的招标网;采招网是中国招标网站采购领域的最佳资讯和交易招标网站，为各级政府采购、招标代理机构、招标企业、供应商提供强大的专业招标采购信息查询和相关服务,中国第一招标网",
						imgUrl: "https://img.bidcenter.com.cn/app/images/logo.png"
					};
					plus.share.sendWithSystem({
						type: "text",
						title: shareInfo.title || "",
						thumbs: [shareInfo.imgUrl || ""],
						href: shareInfo.href || "",
						content: shareInfo.desc || "",
					})
				}
			},
			copyLink() {
				/**
				 * 信息标题+五个空格+ m站链接
				 * 招中标 https://m.bidcenter.com.cn/news-1-332510527.html
				 * 项目   https://m.bidcenter.com.cn/xiangmu-10-1853464.html
				 * 企情  用户中心链接https://user.bidcenter.com.cn/v2023/#/saasApply/qiqing/zhongbiaofenxi/0B4CFAB51A2379A4C5E93662C80E8C59D2A512E1275DD3862D2CFA2C22FB6CF2EE358A47A53F867EC6DF59F2BCA38CA89DC4A053C647DC1A62F594ABE6991E79
				 * /7B19E61FBDCEC2A76D3E66E10149D07846E4AD88B921E810CE5DED201D81695CDB40B9BBBF5A2338
				 */
				let link = ''
				if (this.from == "zhaobiao") {
					link = this.title + '     ' + 'https://m.bidcenter.com.cn/news-' + this.type + '-' + this.ids + '.html'
				} else if(this.from == "gongcheng"){
					link = this.title + '     ' + 'https://m.bidcenter.com.cn/xiangmu-' + this.type + '-' + this.ids +
						'.html'
				}else if(this.from == "qiqing"){
					// 2:业主 5:供应 1:代理
					if(this.danweiType=='2'){
						link=this.title + '     ' + 'https://user.bidcenter.com.cn/v2023/#/saasApply/qiqing/zhaobiaofenxi/' + this.comcode+'/'+this.vcode
						
					}else if(this.danweiType=='5'){
						link=this.title + '     ' + 'https://user.bidcenter.com.cn/v2023/#/saasApply/qiqing/zhongbiaofenxi/' + this.comcode+'/'+this.vcode
		
					}else if(this.danweiType=='1'){
						link=this.title + '     ' + 'https://user.bidcenter.com.cn/v2023/#/saasApply/qiqing/dailifenxi/' + this.comcode+'/'+this.vcode
					}
					
				}
				uni.setClipboardData({
					data: link,
					success: () => {
						this.$emit('update:showShare', false)
					},
					fail: (err) => {
						console.log(err)
					}

				})
				this.$nextTick(() => {
					uni.getClipboardData({
						success: function(res) {
							console.log('剪切板内容', res.data);
						}
					});
				})
			},
			copyTitle() {
				/**
				 * 信息标题+五个空格+ 出处：采招网
				 */
				const title = this.title + '     ' + '出处：采招网'
				uni.setClipboardData({
					data: title,
					success: () => {
						this.$emit('update:showShare', false)
					},
					fail: (err) => {
						console.log(err)
					}
				})
			},
			clickGengduo() {
				if ((uni.getSystemInfoSync().platform == 'ios' && this.ids > 0) || (uni.getSystemInfoSync().platform == 'ios' && this.comcode.length && this.vcode.length)) {
					this.closeShare()
					let shareData = {}
					if (this.from == 'zhaobiao') {
						shareData = {
							shareImg: 'https://img.bidcenter.com.cn/app/images/logo.png',
							shareUrl: "https://interface.bidcenter.com.cn/web/share/zbshare.aspx?id=" + this.ids,
							shareTitle: this.title || "采招网--招标网|招标公告|工程招标采购信息",
							shareContent: "中国采招网是招标网中致力于为企业提供招标、采购、拟在建项目信息及网上招标采购等服务的招标网;采招网是中国招标网站采购领域的最佳资讯和交易招标网站，为各级政府采购、招标代理机构、招标企业、供应商提供强大的专业招标采购信息查询和相关服务,中国第一招标网"
						};
					} else if(this.from == "gongcheng"){
						shareData = {
							shareImg: 'https://img.bidcenter.com.cn/app/images/logo.png',
							shareUrl: "https://interface.bidcenter.com.cn/web/share/xmshare.aspx?id=" + this.ids,
							shareTitle: this.title || "采招网--招标网|招标公告|工程招标采购信息",
							shareContent: "中国采招网是招标网中致力于为企业提供招标、采购、拟在建项目信息及网上招标采购等服务的招标网;采招网是中国招标网站采购领域的最佳资讯和交易招标网站，为各级政府采购、招标代理机构、招标企业、供应商提供强大的专业招标采购信息查询和相关服务,中国第一招标网"
						};
					}else if(this.from == "qiqing"){
						// 2:业主 5:供应 1:代理
						if(this.danweiType=='2'){
							shareData = {
								shareImg: 'https://img.bidcenter.com.cn/app/images/logo.png',
								shareUrl: "https://user.bidcenter.com.cn/v2023/#/saasApply/qiqing/zhaobiaofenxi/" + this.comcode+'/'+this.vcode,
								shareTitle: this.title || "采招网--招标网|招标公告|工程招标采购信息",
								shareContent: "中国采招网是招标网中致力于为企业提供招标、采购、拟在建项目信息及网上招标采购等服务的招标网;采招网是中国招标网站采购领域的最佳资讯和交易招标网站，为各级政府采购、招标代理机构、招标企业、供应商提供强大的专业招标采购信息查询和相关服务,中国第一招标网"
							};
						}else if(this.danweiType=='5'){
							shareData = {
								shareImg: 'https://img.bidcenter.com.cn/app/images/logo.png',
								shareUrl: "https://user.bidcenter.com.cn/v2023/#/saasApply/qiqing/zhongbiaofenxi/" + this.comcode+'/'+this.vcode,
								shareTitle: this.title || "采招网--招标网|招标公告|工程招标采购信息",
								shareContent: "中国采招网是招标网中致力于为企业提供招标、采购、拟在建项目信息及网上招标采购等服务的招标网;采招网是中国招标网站采购领域的最佳资讯和交易招标网站，为各级政府采购、招标代理机构、招标企业、供应商提供强大的专业招标采购信息查询和相关服务,中国第一招标网"
							};
						}else if(this.danweiType=='1'){
							shareData = {
								shareImg: 'https://img.bidcenter.com.cn/app/images/logo.png',
								shareUrl: "https://user.bidcenter.com.cn/v2023/#/saasApply/qiqing/dailifenxi/" + this.comcode+'/'+this.vcode,
								shareTitle: this.title || "采招网--招标网|招标公告|工程招标采购信息",
								shareContent: "中国采招网是招标网中致力于为企业提供招标、采购、拟在建项目信息及网上招标采购等服务的招标网;采招网是中国招标网站采购领域的最佳资讯和交易招标网站，为各级政府采购、招标代理机构、招标企业、供应商提供强大的专业招标采购信息查询和相关服务,中国第一招标网"
							};
						}
						
					}
					// 调用
					let shareObj = appShare(shareData, res => {
						console.log("分享成功回调", res);
						closeShare();
					});
				} else {
					let shareInfo = {
						href: "https://m.bidcenter.com.cn/help/downloadapp.shtml", //"https://interface.bidcenter.com.cn/web/share/zbshare.aspx?id=" + this.detailData.id,
						title: this.title || "采招网-招标网|招标公告|工程招标采购信息",
						desc: this.title ||
							"中国采招网是招标网中致力于为企业提供招标、采购、拟在建项目信息及网上招标采购等服务的招标网;采招网是中国招标网站采购领域的最佳资讯和交易招标网站，为各级政府采购、招标代理机构、招标企业、供应商提供强大的专业招标采购信息查询和相关服务,中国第一招标网",
						imgUrl: "https://img.bidcenter.com.cn/app/images/logo.png"
					};
					plus.share.sendWithSystem({
						type: "text",
						title: shareInfo.title || "",
						thumbs: [shareInfo.imgUrl || ""],
						href: shareInfo.href || "",
						content: shareInfo.desc || "",
					})
				}
			},
		}
	}
</script>

<style lang="scss" scoped>
	.title {
		margin-top: 28rpx;
		font-size: 28rpx;
		color: #3B3E45;
		text-align: center;
		font-weight: bold;
	}

	.share-info {
		display: flex;
		padding: 48rpx 0 70rpx;

		.share-item {
			width: 25%;
			font-size: 24rpx;
			color: #3B3E45;
			font-weight: bold;
			text-align: center;

			image {
				width: 60rpx;
				height: 60rpx;
			}
		}

	}
</style>